//
//  UITextView+Multicast.m
//  Tsc_IOS
//
//  Created by Rio on 15-10-19.
//  Copyright (c) 2015年 idream. All rights reserved.
//

#import "TSCMyMulticastDelegate.h"
#import "UITextView+Multicast.h"
#import  <objc/runtime.h>


@implementation UITextView (Multicast)

NSString* const UITextViewMulticastDelegateKey = @"multicastDelegate";

- (TSCMyMulticastDelegate *)multicastDelegate
{
    // do we have a SHCMulticastDelegate associated with this class?
    id multicastDelegate = objc_getAssociatedObject(self, (__bridge const void *)(UITextViewMulticastDelegateKey));
    if (multicastDelegate == nil) {
        
        // if not, create one
        multicastDelegate = [[TSCMyMulticastDelegate alloc] init];
        objc_setAssociatedObject(self, (__bridge const void *)(UITextViewMulticastDelegateKey), multicastDelegate, OBJC_ASSOCIATION_RETAIN);
        
        // and set it as the delegate
        self.delegate = multicastDelegate;
    }
    
    return multicastDelegate;
}

@end
